package com.dream.common.utils;

import com.dream.common.utils.payutils.bean.WorkedRedPackageBean;
import com.dream.common.utils.payutils.bean.configuration.NextSenderRuleBean;
import com.dream.entity.PickUserInfoBean;
import com.dream.entity.RemindNextSenderBean;
import com.dream.service.DelayRelayQueue;
import com.dream.service.basic.BaseServiceHelper;

import javax.annotation.Resource;
import java.util.List;

public class NextSendRemindUtils {

    public static void nextSendRemind(String userName, WorkedRedPackageBean nextSenderWorkedRedPackageBean, NextSenderRuleBean nextSenderRule) {
        List<PickUserInfoBean> pickUserList = nextSenderWorkedRedPackageBean.pickUserList;
        for (PickUserInfoBean pickUserInfoBean : pickUserList) {
            if (pickUserInfoBean.isNextSendUser) {
                RemindNextSenderBean atNextSenderBean = null;
                RemindNextSenderBean kickNextSenderBean = null;
                //添加at伐包提醒
                if (nextSenderRule.atNextSenderSwitch && nextSenderRule.atNextSenderTime > 0) {
                    atNextSenderBean = new RemindNextSenderBean();
                    atNextSenderBean.username = userName;
                    atNextSenderBean.nextSendUserId = pickUserInfoBean.userID;
                    atNextSenderBean.nextSendUsername = pickUserInfoBean.username;
                    atNextSenderBean.nextSendAtTime = nextSenderRule.atNextSenderTime;
                    atNextSenderBean.relayDisposeType = 1;
                }
                //添加踢人伐包提醒
                if (nextSenderRule.kickNextSenderSwitch && nextSenderRule.kickNextSenderTime > 0) {
                    kickNextSenderBean = new RemindNextSenderBean();
                    kickNextSenderBean.username = userName;
                    kickNextSenderBean.nextSendUserId = pickUserInfoBean.userID;
                    kickNextSenderBean.nextSendUsername = pickUserInfoBean.username;
                    kickNextSenderBean.nextSendKickTime = nextSenderRule.kickNextSenderTime;
                    kickNextSenderBean.relayDisposeType = 2;
                }
                if (atNextSenderBean != null || kickNextSenderBean != null) {
                    BaseServiceHelper.getDelayRelayQueue().resetQueueByUsername(userName, atNextSenderBean, kickNextSenderBean);
                }
            }
        }
    }
}
